package com.jimmy.test;

import com.jimmy.ioc.config.MainConfig;
import com.jimmy.ioc.config.MainConfig2;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @version 1.0
 * @ ClassName AppConfig
 * <p> 基于注解
 * @ author JIMMY
 * @ Date 2020/12/6 0006 下午 8:59
 */
public class AppConfig2 {
    ApplicationContext ctx = new AnnotationConfigApplicationContext(MainConfig2.class);
    @Test
    public void test(){
//        Person person = (Person) ctx.getBean("person");
//        System.out.println(person);

        String[] beanDefinitionNames = ctx.getBeanDefinitionNames();
        for (String beanDefinitionName : beanDefinitionNames) {
            System.out.println(beanDefinitionName);
        }
        System.out.println("--------------");
        Object colorFactoryBean = ctx.getBean("colorFactoryBean");
        System.out.println(colorFactoryBean.getClass());   //返回的其实是  class com.jimmy.ioc.bean.Color
    }


}
